/*
 * OccurrenceSet.cpp
 *
 *  Created on: Mar 5, 2011
 *      Author: Craig Wilson
 */
#include"../inc/OccurrenceSet.h"

		ostream &operator<<(ostream &stream, OccurrenceSet *set){
			  stream << "Test";
			  return stream;
		}

	OccurrenceSet::OccurrenceSet(){
		sites= BST<Occurrence>();
	}

	OccurrenceSet::OccurrenceSet(const OccurrenceSet &other){
		sites= other.sites;
	}

	OccurrenceSet::~OccurrenceSet(){

	}

    void OccurrenceSet::add(Page &site){		//Increments the given word is found;
    	Occurrence temp(site);
    	if (!contains(site)){
    		temp.increment();
    		sites.Insert(temp);
    	}
    	else
    		sites.FindItem(temp)->increment();
    }
    bool OccurrenceSet::contains(Page &site){	//Checks a Page is in the set
    	Occurrence temp(site);
    	if (sites.FindItem(temp)==NULL)
    		return false;
    	return true;
    }

    Occurrence* OccurrenceSet::get(Page &site){  //Returns the occurance given a specific site
    	Occurrence temp(site);
    	return sites.FindItem(temp);
    }

    LinkedList<Occurrence>* OccurrenceSet::toLinkedList(){
    	return sites.toLinkedList();
    }
